
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 10/12/2012 10:12:39
-- Generated from EDMX file: C:\Users\Nick\Documents\Visual Studio 2012\Projects\ESiLoot\LootPoints\LootPoints\Model.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [ESiLootPoints];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_CharacterLootLog]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[LootLog] DROP CONSTRAINT [FK_CharacterLootLog];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Character]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Character];
GO
IF OBJECT_ID(N'[dbo].[LootLog]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LootLog];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Character'
CREATE TABLE [dbo].[Character] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Race] nvarchar(max)  NOT NULL,
    [Class] nvarchar(max)  NOT NULL,
    [Level] int  NOT NULL,
    [Password] nvarchar(max)  NOT NULL,
    [Admin] bit  NOT NULL,
    [Reset] bit  NOT NULL,
    [Email] nvarchar(max)  NOT NULL,
    [ResetCode] nvarchar(max)  NULL,
    [Group] nvarchar(max)  NULL,
    [Rank] nvarchar(max)  NULL,
    [EP] int  NOT NULL,
    [GP] int  NOT NULL
);
GO

-- Creating table 'LootLog'
CREATE TABLE [dbo].[LootLog] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [CharacterId] int  NOT NULL,
    [Item] nvarchar(max)  NULL,
    [ArmoryId] int  NOT NULL,
    [GP] int  NOT NULL,
    [Datetime] datetime  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'Character'
ALTER TABLE [dbo].[Character]
ADD CONSTRAINT [PK_Character]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'LootLog'
ALTER TABLE [dbo].[LootLog]
ADD CONSTRAINT [PK_LootLog]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [CharacterId] in table 'LootLog'
ALTER TABLE [dbo].[LootLog]
ADD CONSTRAINT [FK_CharacterLootLog]
    FOREIGN KEY ([CharacterId])
    REFERENCES [dbo].[Character]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CharacterLootLog'
CREATE INDEX [IX_FK_CharacterLootLog]
ON [dbo].[LootLog]
    ([CharacterId]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------